﻿using System.ComponentModel.Composition;
using System.Windows.Forms;
using Polenter.Mcm;

namespace McmWinFormsApplication1.Components
{
    /// <summary>
    ///     A component can manage its state, it can access other components using its Components property
    /// </summary>
    [Export(typeof (McmComponent))]
    public class ErrorPresenterComponent : McmComponent
    {
        [MessageSubscriber(McmComponentContainer.MessagesChannelName,
            UIThreadSynchronizationMode.PostAsynchronousInUIThread)]
        private void handleAsyncOperationResponseMessage(AsyncOperationResponseMessage m)
        {
            if (m.HasError)
            {
                MessageBox.Show(m.Error.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}